﻿'This interface allow the MapWindow plugin to launch WRDB remotely

<CLSCompliant(True)> _
Public Interface clsWRDB
    Sub ShowMainFormMW()
    Function GetMainFormMW() As System.Windows.Forms.Form
    Sub CloseMainFormMW()
    Event Closed()
    Sub MapMouseMove(ByVal ScreenX As Integer, ByVal ScreenY As Integer)
    Sub MapExtentsChanged()
    Sub ShapesSelected()
End Interface

Public Class clsAccessWRDB
    Const REGAPP As String = "WRDB"

    Public Shared Function DLLPath() As String
        If False AndAlso Diagnostics.Debugger.IsAttached And Environment.UserName.Contains("LCW") Then
            Return "C:\Projects\WRDB 5.1\bin"
        Else
            Return GetSetting(REGAPP, "Defaults", "DLL Path 5.1", "C:\Program Files\Water Resources Database 5.1")
        End If
    End Function

    Public Shared Function WRDBIsInstalled(Optional ByRef ErrorMsg As String = "") As Boolean
        If IO.Directory.Exists(DLLPath) AndAlso IO.File.Exists(DLLPath() & "\WRDB.exe") Then
            ErrorMsg = ""
            Return True
        Else
            ErrorMsg = String.Format("Unable to find the necessary WRDB libraries. You must download and install WRDB 5 for this program to run properly (it is available at www.wrdb.com). If you have installed the latest version of WRDB 5 into a non-default drive or directory, you must run the stand-alone version of WRDB at least once so it can register its location and thus allow this application to find it.")
            Return False
        End If
    End Function

    Public Shared Function LaunchWRDB() As Boolean
        If WRDBIsInstalled() Then
            Shell(DLLPath() & "\WRDB.exe", AppWinStyle.NormalFocus)
            Return True
        Else
            Return False
        End If
    End Function

    Public Shared Function LaunchWRDBGraph() As Boolean
        If WRDBIsInstalled() Then
            Shell(DLLPath() & "\WRDBGraph.exe", AppWinStyle.NormalFocus)
            Return True
        Else
            Return False
        End If
    End Function

End Class

